var path="http://localhost:8080/ddln-order";
var total=0;
var pageSize=0;
var shipping_id="0";
var orderId="";
$(function(){ 
	 orderId=getUrlParam("orderId")
	$.ajax({ 
		type:"POST",
		url:path+"/order/order/getOrderById", 
		data:{"orderId":orderId},       
		dataType:"json",
		async: false,   
		success:function(data){  
			if(data.success=="true"){ 
				   
				var status="";
				var pay_status="";
				var ship_status="";
				var payment="";
				
				if(data.data.status=="0"){
					status="已取消"
				}else{
					status="已提交"
				}
				
				if(data.data.pay_status=="0"){
					pay_status="未付款"
				}else{
					pay_status="已付款"
				}
				

				if(data.data.ship_status=="0"){
					ship_status="未发货"
				}else{
					ship_status="已发货"
				}
				
				if(data.data.payment_id=="1"){
					payment="支付宝支付"
				}else if(data.data.payment_id=="2"){
					payment="微信支付"
				}else{
					payment="账户余额"
				}
				
				$("#status").text(status);
				$("#pay_status").text(pay_status);
				$("#ship_status").text(ship_status);
				$("#payment").text(payment);       	
				$(".orderSn").text(data.data.sn);
				$("#orderGoodsName").text(data.data.goods.name);
				$("#orderGoodsPrice").val(data.data.goods.price);
				$("#orderGoodsNum").val(data.data.goods_num);  
				$(".orderGoodsAmount").text(data.data.goods_amount);
				$("#orderCteateTime").val(data.data.cteatetime);
				$("#consigneeName").val(data.data.address.name);  
				$("#consigneeMoblie").val(data.data.address.mobile); 
				$("#consigneeZip").val(data.data.address.zip);    
				$("#consigneeAddress").val(data.data.address.province.name+" "+data.data.address.city.name+" "+data.data.address.region.name+" "+data.data.address.town.name+" "+data.data.address.addr);
				$("#consigneeRemark").val(data.data.remark);       
				
				
			}else{ 
			}
		   
		    
		},
		error:function(data){ 
			//alert("对不起，加载失败");
		}
	}); 
	
	$("#updateOrder").click(function() {    
		alert(shipping_id);     
		
	})
	
	
	
	
	
	
	
});

	
    

$(function () {
	
	
})
function selectCheck(dom) {
	shipping_id=dom; 
	var ship_status=0;
	if(shipping_id!="0"){  
		ship_status=1;
	}
	$.ajax({ 
		type:"POST",
		url:path+"/order/order/updateOrder",   
		data:{"order_id":orderId,"shipping_id":shipping_id,"ship_status":ship_status},  
		dataType:"json", 
		success:function(data){   
			if(data.success=="true"){
				alert("修改成功");     
			}else{
				alert("修改失败");       
			}
		
		    
		},
		error:function(data){ 
			//alert("对不起，删除失败");
		}
	});
}


function getUrlParam(name){  
	//构造一个含有目标参数的正则表达式对象  
	var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");  
	//匹配目标参数  
	var r = window.location.search.substr(1).match(reg);  
	//返回参数值  
	if (r!=null) return unescape(r[2]);  
	return null;  
	}  
